﻿using System;

using Holdem.Interfaces.Attributes.Config;
using Holdem.Interfaces.Configuration;
using Holdem.Interfaces.Service;

namespace Holdem.Service
{
	public class HoldemConfigurationService : IConfigurationService
	{
		private readonly IHoldemPhoneConfiguration _transientConfiguration;
		private readonly IHoldemPhoneConfiguration _persistentConfiguration;
		private readonly IHoldemIsolatedStorageFile _isolatedStorage;

		#region Implementation of IConfigurationService

		public IHoldemPhoneConfiguration TransientConfiguration { get { return _transientConfiguration; } }
		public IHoldemPhoneConfiguration PersistentConfiguration { get { return _persistentConfiguration; } }
		public IHoldemIsolatedStorageFile IsolatedStorage { get { return _isolatedStorage; } }

		#endregion

		public HoldemConfigurationService(
            [TransientConfiguration] IHoldemPhoneConfiguration transientConfiguration,
            [PersistentConfiguration] IHoldemPhoneConfiguration persistentConfiguration,
			IHoldemIsolatedStorageFile isolatedStorage)
		{
			if (transientConfiguration == null)
				throw new ArgumentNullException("transientConfiguration");
			if (persistentConfiguration == null)
				throw new ArgumentNullException("persistentConfiguration");
			if (isolatedStorage == null)
				throw new ArgumentNullException("isolatedStorage");

			_transientConfiguration = transientConfiguration;
			_persistentConfiguration = persistentConfiguration;
			_isolatedStorage = isolatedStorage;
		}
	}
}